<div class="form-inline">
  <div class="form-inline pull-left">
    <button *ngIf="selectStatus == '1' && canVisit" type="button" class="btn btn-success" (click)="showAddModal()">新建机器人</button>
    <!--<button type="button" class="btn"-->
            <!--[ngClass]="{'btn-success': selectStatus === '1','btn-default': selectStatus !== '1'}"-->
            <!--(click)="selectStatus = '1';getList();">机器人列表-->
    <!--</button>-->
    <!--<button type="button" class="btn"-->
            <!--[ngClass]="{'btn-success': selectStatus === '2','btn-default': selectStatus !== '2'}"-->
            <!--(click)="selectStatus = '2';getList();">积分列表-->
    <!--</button>-->
  </div>
  <div class="pull-right">
    <!--<button *ngIf="selectStatus == '1'" type="button" class="btn btn-success" (click)="showAddModal()">新建机器人</button>-->
  </div>
</div>
<ng-container *ngIf="selectStatus == '1'">
  <div class="table-responsive">
    <nz-spin [nzTip]="'正在读取机器人列表...'" [nzSpinning]="_isSpinning" [nzSize]="'large'" class="admin-spin">
      <table class="table">
        <thead>
        <tr>
          <th>id</th>
          <th style="width:200px;">机器人名称</th>
          <th>机器人手机号</th>
          <th style="width:200px;">小店头像</th>
          <th>机器人周积分</th>
          <th>机器人月积分</th>
          <th>创建时间</th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let item of robotList">
          <td>{{item.id}}</td>
          <td>{{item.nickName}}</td>
          <td>{{item.mobile}}</td>
          <td *ngIf="item.member_store.avatar_url">
            <img src="{{item.member_store.avatar_url }}" alt="" style="width:50px;height:50px;border-radius:50%;">
          </td>
          <td *ngIf="!item.member_store.avatar_url"></td>
          <td>{{ item.week_point }}</td>
          <td>{{ item.month_point }}</td>
          <td>{{ item.created_at }}</td>
          <td>
            <a href="javascript:;" *ngIf="canVisit2" (click)="showAddIntergral(item.id)">增加积分</a>
            <a href="javascript:;" *ngIf="canVisit1" (click)="showConfirmModal(item.id)">删除</a>
          </td>
        </tr>
        </tbody>
      </table>
    </nz-spin>
  </div>

</ng-container>
<ng-container *ngIf="selectStatus == '2'">
  <div class="table-responsive">
    <nz-spin [nzTip]="'正在读取机器人积分列表...'" [nzSpinning]="_isSpinning" [nzSize]="'large'" class="admin-spin">
      <table class="table">
        <thead>
        <tr>
          <th style="width:300px;">id</th>
          <th style="width:200px;">机器人名称</th>
          <th>机器人积分</th>
          <th style="width:400px;">生成时间</th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let item of IntegralList">
          <td>{{item.member_info.id}}</td>
          <td>{{item.member_info.nickName}}</td>
          <td>{{item.point}}</td>
          <td>{{item.created_at}}</td>
          <td>
            <a href="javascript:;" *ngIf="canVisit3" (click)="showConfirmModal(item.id)">删除</a>
          </td>
        </tr>
        </tbody>
      </table>
    </nz-spin>
    <div class="text-center">
      <pagination (pageChanged)="pageChanged($event)" [totalItems]="totalItems" [(ngModel)]="currentPage"
                  [itemsPerPage]="itemsPerPage"
                  [maxSize]="10"
                  previousText="&lsaquo;" nextText="&rsaquo;" firstText="&laquo;" lastText="&raquo;"
                  [boundaryLinks]="true" class="pagination-sm"></pagination>
    </div>
  </div>
</ng-container>


<app-notification [type]="type" [message]="message" [isShow]="isShow"
                  (promptIsShow)="isShow = $event;"></app-notification>

<div class="modal fade" bsModal #addIntegralModal="bs-modal" tabindex="-1">
  <div class="modal-dialog modal-xs">
    <form #addIntegralForm="ngForm">
      <div class="modal-content">
        <div class="modal-header">
          <h4 class="modal-title pull-left">增加积分</h4>
          <button type="button" class="close pull-right" aria-label="Close"
                  (click)="cancelIntegral()">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <div class="modal-body">
          <div class="form-group clearfix">
            <label class="col-md-2">增加积分:</label>
            <div class="col-md-8">
              <input type="number" class="form-control" [(ngModel)]="integral" (ngModelChange)="checkIntegral()" [ngModelOptions]="{standalone: true}" required>
            </div>
          </div>
          <div class="form-group clearfix">
            <label class="col-md-2">时间:</label>
            <div class="col-md-8">
              <nz-datepicker
                [(ngModel)]="_date"
                [nzSize]="'large'"
                style="width:350px;"
                [nzPlaceHolder]="'请选择时间'"
                [nzFormat]="'YYYY/MM/DD HH:mm:ss'"
                [nzAllowClear]="false"
                nzShowTime
                [nzShowTime]="true"
                [ngModelOptions]="{standalone: true}">
              </nz-datepicker>
            </div>
          </div>
          <div class="text-center mt20">
            <button class="btn btn-default btn-md-long" type="button"
                    (click)="cancelIntegral()">取 消
            </button>
            <button class="btn btn-success btn-md-long" type="button" [disabled]="IntegralError"
                    (click)="addRobotIntegral();">添 加
            </button>
          </div>
        </div>
      </div>
    </form>
  </div>
</div>


<div class="modal fade" bsModal #addModal="bs-modal" tabindex="-1">
  <div class="modal-dialog modal-xs">
    <form #addForm="ngForm">
      <div class="modal-content">
        <div class="modal-header">
          <h4 class="modal-title pull-left">新建机器人</h4>
          <button type="button" class="close pull-right" aria-label="Close"
                  (click)="cancel()">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <div class="modal-body">
          <div class="form-group clearfix">
            <label class="col-md-2">机器人名称:</label>
            <div class="col-md-8">
                <input type="text" class="form-control" name="nickName" [(ngModel)]="addRobot.nickName" required>
            </div>
          </div>
          <div class="form-group clearfix">
            <label class="col-md-2">小店名称:</label>
            <div class="col-md-8">
              <input type="text" class="form-control" name="member_store_name" [(ngModel)]="addRobot.member_store_name" required>
            </div>
          </div>
          <div class="form-group clearfix">
            <label class="col-md-2">机器人头像:</label>
            <div class="col-md-8">
              <app-upload [(fileList)]="fileList" [(piclist)]="picList" [picSizeInfo]="picSizeInfo" [outMargin]="'20px'"
                          (piclistChange)="fileChange()" (fileListChange)="fileChange()" [canChange]="canChange">
              </app-upload>
              <div *ngIf="picError" style="color:red;">请上传一张图片</div>
            </div>
          </div>
          <div class="text-center mt20">
            <button class="btn btn-default btn-md-long" type="button"
                    (click)="cancel()">取 消
            </button>
            <button class="btn btn-success btn-md-long" type="button"
                    [disabled]="!addForm.form.valid || !addRobot.avatar_url"
                    (click)="addRobot1();">添 加
            </button>
          </div>
        </div>
      </div>
    </form>
  </div>
</div>

<div class="modal fade" bsModal #confirmModal="bs-modal" tabindex="-1">
  <div class="modal-dialog modal-xs">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title pull-left">温馨提示</h4>
        <button type="button" class="close pull-right" aria-label="Close" (click)="confirmModal.hide()">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <div class="form-group clearfix">
          <p>您确定要删除吗？</p>
        </div>
        <form>
          <div class="text-center mt20">
            <button class="btn btn-default btn-md-long" type="button" (click)="confirmModal.hide();">取消</button>
            <button class="btn btn-success btn-md-long" type="submit"
                    (click)="selectStatus == '1' ? deleteRobot() : deleteIntegral();">确定
            </button>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>


